# Maintainer: Sven-Hendrik Haase <svenstaro@archlinux.org>
# Contributor: Nathaniel Chin <thegamingorangutans+aur at gmail.com>

pkgname=av1an
pkgver=0.4.1
pkgrel=1
pkgdesc='Cross-platform command-line encoding framework with per scene quality encoding'
arch=('loong64' 'x86_64')
url='https://github.com/master-of-zen/Av1an'
license=('GPL3')
makedepends=('rust' 'nasm' 'clang')
depends=('ffmpeg' 'aom' 'vapoursynth')
optdepends=('svt-av1: SVT-AV1 encoder support'
            'rav1e: rav1e encoder support'
            'libvpx: vpx encoder support'
            'vmaf: VMAF calculation support'
            'mkvtoolnix-cli: mkvmerge support'
            'ffms2: FFMS2 chunk detection support'
            'vapoursynth-plugin-lsmashsource: L-SMASH chunk detection support')
source=("$pkgname-$pkgver.tar.gz"::https://github.com/master-of-zen/Av1an/archive/refs/tags/$pkgver.tar.gz)
sha256sums=('a67fd182a2c70560fb86857e625eece5dabc42cd380b3ed345939ebbbc4a691d')

build() {
  cd "Av1an-${pkgver}"
  export CFLAGS+=" -ffat-lto-objects"
  cargo build --release --locked
}

package() {
  cd "Av1an-${pkgver}"
  install -Dm755 target/release/av1an "${pkgdir}/usr/bin/av1an"
  install -Dm644 LICENSE.md "${pkgdir}"/usr/share/licenses/$pkgname/LICENSE.md
}
